/*
    XTU OJ: 1474
    by: fifth_light
*/

#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a1, b1, c1, a2, b2, c2;
        scanf("%d%d%d%d%d%d", &a1, &b1, &c1, &a2, &b2, &c2);
        int result = 0;
        do {
            if (a1 > a2) {
                result = 1;
                break;
            }
            if (a1 < a2) {
                result = -1;
                break;
            }
            if (b1 > b2) {
                result = 1;
                break;
            }
            if (b1 < b2) {
                result = -1;
                break;
            }
            if (c1 > c2) {
                result = 1;
                break;
            }
            if (c1 < c2) {
                result = -1;
                break;
            }
        } while (0);
        if (result == 1) {
            printf("former\n");
        } else if (result == -1) {
            printf("latter\n");
        } else {
            printf("same\n");
        }
    }
    return 0;
}
